<?PHP
//session_start();
include("../public/common.php");
include("../config/connect.php");

$opt = CheckUrlParamNoDie("opt");
$id = HasLogin() ? $_COOKIE["gwt_userid"] : "";
if ($id == "" && isset($_SERVER["HTTP_TB_ID"]) && trim($_SERVER["HTTP_TB_ID"]) != "")
{
	$sql = "select id from user where tb_id='".$_SERVER["HTTP_TB_ID"]."' limit 1";
	$result = mysql_query( $sql );
	$row = mysql_fetch_assoc( $result );
	$id = $row["id"];
}
if ($id == "")
	$id = CheckUrlParamNoDie("id");	
if ($id == "")
{
	echo "error";
	exit;
}

//
$sql = "select id, tb_id, password, level, tubi, type from user where id=$id limit 1";
$result = mysql_query( $sql );
$row = mysql_fetch_assoc( $result );
$userid = $row["id"];
$pwd = $row["password"];
$tb_id = $row["tb_id"];
$user_type = $row["type"];
$level = $row["level"];
$tubi = $row["tubi"];
$code = MakeRecommendCodeFrom($id, $user_type);
$levelData = GetTubi($level);

//该ID没有设置密码，跳转到设置密码页面
if($opt != "no" || !isset($opt))
{
	if($pwd == "")
	{
		$url = "Location:add_psw.php?id=$userid";
		header($url);
		exit;
	}
	else if(!HasLogin()) 
	{
		$url = "Location:login.php?id=$userid&ref=./";
		header($url);
		exit;
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>个人中心</title>
<style type="text/css">
body {font-size: 12px;color: #000;font-family: 宋体; background:#FFF;}
.STYLE1 {font-size: 13px;font-weight: bold;}
table {border-collapse:collapse; border-spacing:2px;  font-size:12px;}
td,th { display:table-cell; vertical-align:inherit;}
img { border:0; vertical-align:top;}
/*tc*/
.message_tc .li_pic { float:left; width:120px;}
.message_tc .li_pic p.s1 {border:1px solid #E3E3E3;margin:0;height:120px;padding:2px;vertical-align:middle;width:120px;overflow:hidden; }
.message_tc .li_pic p.s2 { height:20px; margin:0; width:126px; line-height:20px; overflow:hidden; text-align:center;}
.message_tc .li_pic img { height:120px; max-width:120px; vertical-align:middle;}
.message_tc .li_title { float:left; width:130px; padding-left:10px;}
.message_tc .li_title .s1 { text-indent:20px; font-size:14px;}
.message_tc .li_title p { margin:0; line-height:25px;}
</style>
<script language="javascript">
function OnG1B11(obj)
{
	document.getElementById("g1b1_ok_id").src = "images/group1_h.png";
	document.getElementById("g1b1_id").src = "images/group1_1.png";
	document.getElementById("g1b1_other_id").src = "images/group1_2.png";
	document.getElementById("commision_id").src = "commision_info_ok.php?tb_id=<?PHP echo $tb_id; ?>&id=<?PHP echo $id; ?>";
}
function OnG1B12(obj)
{
	document.getElementById("g1b1_id").src = "images/group1_1_h.png";
	document.getElementById("g1b1_ok_id").src = "images/group1.png";
	document.getElementById("g1b1_other_id").src = "images/group1_2.png";
	document.getElementById("commision_id").src = "commision_info.php?tb_id=<?PHP echo $tb_id; ?>&id=<?PHP echo $id; ?>";
}
function OnG1B13(obj)
{
	document.getElementById("g1b1_other_id").src = "images/group1_2_h.png";
	document.getElementById("g1b1_id").src = "images/group1_1.png";
	document.getElementById("g1b1_ok_id").src = "images/group1.png";
	document.getElementById("commision_id").src = "mall_commision_info.php?tb_id=<?PHP echo $tb_id; ?>&id=<?PHP echo $id; ?>";
}

function OnG1B21(obj)
{
	document.getElementById("g1b2_1_id").src = "images/group2_1_h.png";
	document.getElementById("g1b2_2_id").src = "images/group2_2.png";
	document.getElementById("recommend_id").src = "recommend_info.php?tb_id=<?PHP echo "tb_id=$tb_id&id=$id&type=$user_type"; ?>";
}
function OnG1B22(obj)
{
	document.getElementById("g1b2_1_id").src = "images/group2_1.png";
	document.getElementById("g1b2_2_id").src = "images/group2_2_h.png";
	document.getElementById("recommend_id").src = "recommend_fee.php?tb_id=<?PHP echo "tb_id=$tb_id&id=$id&type=$user_type"; ?>";
}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<table width="920" border="1" cellpadding="0" cellspacing="0" align="center" bordercolor="#a8a8a8">
  <tr>
    <td class="y">
<table width="920" height="102" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="920" valign="top"><a href="http://url.cn/10vU2H" target="_blank" title="Q+购物兔返利，让您的生活更加精彩与美好！"><img src="images/gg/top.gif" alt="Q+购物兔返利，让您的生活更加精彩与美好！" /></a></td>
  </tr>
</table>

<table width="920" align="center" cellpadding="0" cellspacing="0" border="0" style="background:#eee url(images/bg2011102601.jpg);">
  <tr>
    <td height="40" colspan="2" style="background:url(images/bg2011102602.jpg) no-repeat center bottom;"><div style=" position:relative;"><span class="STYLE1">&nbsp;尊敬的  <?PHP echo $tb_id." "; if ($user_type == 'N') echo "用户"; else echo "联盟用户"; ?>，您好：&nbsp;</span>
	<?php
		if(HasLogin()) {
	?>
    <a href="../register_nocheck.php?opt=logout" style="position:absolute; right:44px; top:5px;">[注销]</a><?php } ?></div></td>
  </tr>
  <tr>
    <td width="500" height="24" style="padding-left:50px;">
    	<table>
        	<tr>
            	<td height="40"><b>等级<span id="Degree"><?PHP echo $levelData["level"] ?></span>：</b><font style="font-size:12px;" id="designation"><?PHP echo $levelData["level_desc"] ?></font></td>
                <td height="40" style="padding-left:20px;">
                	 <table width="200" border="0" cellspacing="0" cellpadding="0" bordercolor="#000000">
                        <tr>
                            <td width="4" height="20">
                                <img height="20" src="images/img_left.gif" width="4">
                            </td>
                            <td width="192" background="images/img_backing.gif" height="20" align="left">
                                <div style="position:relative; height:12px; width:192px; overflow:hidden;"><img src="images/orange.gif" id="imgWidth" height="12" width="<?PHP echo $level*100/$levelData["level_max"] ?>%">
                                <span style="position:absolute; top:-2px; *top:0; right:4px; color:#333;"><span id="Ievel">
								<?php if($level=="") echo "0"; else echo $level; ?></span>/<span id="Grade"><?PHP echo $levelData["level_max"] ?></span></span></div> 
                            </td>
                            <td width="4" height="20">
                                <img height="20" src="images/img_right.gif" width="4">
                            </td>
                        </tr>
                    </table>
                </td>
                <?php
					$row = mysql_fetch_assoc(mysql_query("select count(*) as tmp from gwt_msg where see='0' and touser=".$id));
					$allCount = $row["tmp"];
				?>
                <td>&nbsp;&nbsp;&nbsp;&nbsp;<img src="<?php if($allCount != '0' || $allCount == '') echo 'images/laba.gif'; else echo 'images/labajing.gif'; ?>" alt="" />&nbsp;<a href="msg.php" target="_blank" title="点击查看消息" style="text-decoration:none;">消息<?php if($allCount != '0' || $allCount == ''){ ?>（<font color="#FF0000"><?php echo $allCount; ?></font>）<?php } ?></a></td>
            </tr>
        </table>
   	</td>
    <td rowspan="3" style="vertical-align:baseline; padding-left:10px; background:#F4F4F5;">
    <div style="height:40px; padding-top:10px;">
    	<input type="hidden" id="rmdurl_src" value="http://www.gouwutu.com/rmd/<?PHP echo $code; ?>.html"/>
        <b>您的邀请链接是：</b><img src="images/convert.gif" align="absmiddle" title="点击转换为短域名形式的推荐链接" onclick="Convert()"/><br />&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="rmdurl" value="http://www.gouwutu.com/rmd/<?PHP echo $code; ?>.html" style="border:none; font-size:14px; width:286px; background:none" onclick="javascript:select();"/>
        &nbsp;
    </div>
    <div style="height:30px; line-height:30px;"><span>您的邀请码：</span><span style="color:#FF0033; font-weight:bold"><?PHP echo $code; ?></span></div>
    <!-- JiaThis Button BEGIN -->
		
	<div id="ckepop">
	<span class="jiathis_txt" style="font-size:13px;""> 立即推荐给朋友：</span>
    <div onclick="AddTubi()">
	<a class="jiathis_button_qzone"></a>
	<a class="jiathis_button_tsina"></a>
	<a class="jiathis_button_renren"></a>
	<a class="jiathis_button_kaixin001"></a>
	<a href="http://www.jiathis.com/share/?uid=904300" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a>
	<a class="jiathis_counter_style"></a></div></div>

	<!-- JiaThis Button END -->
    </td>
  </tr>
   <tr>
  	<td height="40" style="padding-left:50px;"><b>累积兔币：</b><?php echo $level; ?><b style="padding-left:20px;">余额：</b><?php echo $tubi; ?>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../dh/index.php" target="_blank" style="color:#F00; text-decoration:none;">兑换商品（<b>HOT</b>）</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://bbs.gouwutu.com/forum.php?mod=viewthread&tid=145" style=" text-decoration:none;" target="_blank">赢更多兔币！</a></td>
  </tr>
  <tr>
  	<td height="40" style="padding-left:50px;"></td>
  </tr>
  <tr>
  	<td height="15" colspan="2" style="background:url(images/bg2011102603.jpg) no-repeat center top;"></td>
  </tr>
</table>

<table width="920" height="33" border="0" align="center" cellpadding="0" cellspacing="0" background="images/group_bg.png">
  <tr>
    <td width="25" height="33">&nbsp;</td>
    <td width="443" valign="top"><img id="g1b1_ok_id" src="images/group1_h.png" onclick="OnG1B11()" style="cursor:pointer" />&nbsp;&nbsp;<img src="images/split.png" id="split_g11" />&nbsp;&nbsp;<img id="g1b1_id" src="images/group1_1.png"  onclick="OnG1B12()" style="cursor:pointer" />&nbsp;&nbsp;<img src="images/split.png" id="split_g12" />&nbsp;&nbsp;<img id="g1b1_other_id" src="images/group1_2.png" onclick="OnG1B13()" style="cursor:pointer" /></td>
     <td width="452" align="right"><?PHP 
	$count = mysql_result(mysql_query("select count(*) as tmp from order_handle_report where user_id='".$id."'"), 0, "tmp");
	$sumMoney = mysql_result(mysql_query("select sum(commission)*0.6 as tmp from order_handle_report where user_id='".$id."'"), 0, "tmp");
	if ($sumMoney=="") $sumMoney = 0;
	echo "您共有&nbsp;".$count."&nbsp;笔返现单，购物兔共为您节省了&nbsp;".round($sumMoney,2)."&nbsp;元";
	?>&nbsp;</td>
  </tr>
</table>

<iframe id="commision_id" width="100%" height="240" src="commision_info_ok.php?tb_id=<?PHP echo $tb_id; ?>&id=<?PHP echo $id; ?>" scrolling="no" frameborder="0"></iframe>
<br /><br/>
<table width="920" height="33" border="0" align="center" cellpadding="0" cellspacing="0" background="images/group_bg.png">
  <tr>
    <td width="30" height="33">&nbsp;</td>
    <td width="300" valign="top"><img id="g1b2_1_id" src="images/group2_1_h.png"  onclick="OnG1B21()" style="cursor:pointer" />&nbsp;&nbsp;<img src="images/split.png" id="split_g11" />&nbsp;&nbsp;<img id="g1b2_2_id" src="images/group2_2.png"  onclick="OnG1B22()" style="cursor:pointer" /></td>
    <td width="741" align="right"><span id="allrecommend"><img src="images/loading.gif" align="absmiddle" />&nbsp;加载中，请稍后...</span>&nbsp;</td>
  </tr>
</table>
<iframe id="recommend_id" width="100%" height="240" src="recommend_info.php?<?PHP echo "tb_id=$tb_id&id=$id&type=$user_type"; ?>" scrolling="no" frameborder="0"></iframe>

    </td>
  </tr>
</table>

<table cellpadding="0" cellspacing="0" border="0" width="920" align="center">
<tr>
	<td width="537" height="30" style="padding-left:5px; font-size:12px; color:#666">冰峰科技旗下购物兔 CopyRight 2011 gouwutu.com 粤ICP备11009208号</td>
    <td width="241"><span style="font-size:12px; color:#666">在线QQ客服：<a href="http://wpa.qq.com/msgrd?v=3&amp;uin=1753949757&amp;site=qq&amp;menu=yes" target="_blank"><img align="absmiddle" title="欢迎点击和我们交流" src="http://wpa.qq.com/pa?p=2:1753949757:42" border="0" alt="点击和我们交流" /></a>&nbsp;&nbsp;&nbsp;</span></td>
    <td width="142" height="30" align="right" style="font-size:12px; color:#666"><a href="mailto:admin@gouwutu.com" target="_blank" style="font-size:12px; color:#666; font-weight:400; text-decoration:underline">联系我们</a>&nbsp;&nbsp;&nbsp;&nbsp;</td>
</tr>
</table>
<p />
<!---tc--->
<div style="display:none;" id="showMMM">
<?php
$row2 = mysql_fetch_assoc(mysql_query("select * from gwt_dh_goods where tumoney > $tubi order by tumoney asc limit 1"));
$metubi = $row2["tumoney"];
$shengyutubi = $metubi-$tubi; //还差多少兔币
?>
	<div class="message_tc">
        <div class="li_pic">
            <p class="s1"><a href="http://www.gouwutu.com/dh/index.php?catalog=<?php echo urlencode($row2["dhtag"]); ?>&gid=<?php echo $row2["id"]; ?>" title="<?php echo $row2["dhtitle"]; ?>" target="_blank"><img src="<?php echo $row2["dhpic"]; ?>" alt="<?php echo $row2["dhtitle"]; ?>"></a></p>
            <p class="s2"><a href="http://www.gouwutu.com/dh/index.php?catalog=<?php echo urlencode($row2["dhtag"]); ?>&gid=<?php echo $row2["id"]; ?>" target="_blank" title="<?php echo $row2["dhtitle"]; ?>"><?php echo $row2["dhtitle"]; ?></a></p>
        </div>
        <div class="li_title">
            <p class="s1">您还差&nbsp;<font color="#FF0000"><?php echo $shengyutubi; ?></font>&nbsp;兔币就可以兑换此商品，加油努力哦！</p>
            <p class="li_money">需要兔币：<font color="#FF0000"><?php echo $metubi; ?></font><img width="20" height="20" title="兔币" src="../dh/images/jin.gif" alt="兔币"></p>
            <p class="li_num">商品库存：<font color="#FF0000"><?php echo $row2["dhnumber"]; ?></font></p>
            <p class="li_num"><a href="http://bbs.gouwutu.com/forum.php?mod=viewthread&tid=145" target="_blank"><font color="#FF0000">如何赚取兔币？</font></a></p>
        </div>
    </div>
</div>
<script type="text/javascript" src="http://www.gouwutu.com/n2/v2/css/nav/jquery.js"></script>
<script type="text/javascript" src="messages.js"></script>
</body>
</html>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-20984072-1");
pageTracker._trackPageview();
} catch(err) {}</script>

<script type="text/javascript">
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F7eb75a7b189f4a709dead85bc20eb0dd' type='text/javascript'%3E%3C/script%3E"));
</script>

<script language="javascript">
	var url = "http://www.gouwutu.com/myservices/recommend_count.php?id=<?PHP echo $id; ?>";
	$.ajax({	url: url,
			async: true,
			success:function(result){
//			alert(res);
			document.getElementById("allrecommend").innerHTML = result;
           },
		   failure:function(result){
               document.getElementById("allrecommend").innerHTML = "加载失败，请稍后再试";
           }
		})
</script>

<script language="javascript">
function Convert()
{
	var obj = document.getElementById("rmdurl");
	if (obj.value.indexOf("http://t.cn") == -1)
	{
		var url = "http://www.gouwutu.com/funapi/short_url.php?url=" + obj.value;
		$.ajax({url: url,
				async: false,
				success:function(result){
	//			alert(res);
				obj.value = result;
			   },
			   failure:function(result){
				   alert("转换失败，请重试~");
			   }
			})
	}
	else
	{
		obj.value = document.getElementById("rmdurl_src").value;
	}
}

function AddTubi()
{
	var url = "http://www.gouwutu.com/funapi/opt_tubi.php?userid=<?PHP echo $id ?>&type=r";
	var res = $.ajax({	url: url,
			async: false
		}).responseText;
//	alert(res);
}
</script>

<!-- JiaThis Button BEGIN -->
<script type="text/javascript">
	var jiathis_config = {
		data_track_clickback:true,
		url: "http://www.gouwutu.com",
		title: "我一直使用#购物兔#在淘宝上购物，超简单，通过返现达到真正省钱，而且还能折上再折；更重要的是返现超快，当天直接到账，全自动！如果你经常淘宝，强烈建议用用看，都上QQ新闻了(http://tech.qq.com/a/20110307/000325.htm)！上网搜索一下就知道了~ （分享自 @购物兔）！"
	}
</script>
<script type="text/javascript" src="http://v2.jiathis.com/code/jia.js?uid=904300" charset="utf-8"></script>
<!-- JiaThis Button END -->